<?php
$this->pageTitle = 'Manage My Courses';
$this->menu = array(
    array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('asigntotrainner')),
);
?>

<h3><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?></h3>
<script type="text/javascript">
    function ChangeStatus(id, status)    {
        $.ajax({
            url: "<?php echo $statuschangeurl; ?>",
            type: "post",
            data: "id=" + id + "&status=" + status,
            dataType: "html",
            success: function(msg) {
                $('#courses-grid').yiiGridView.update('courses-grid');
            }
        });

    }
      function gotohome(id, status) {
        $.ajax({
            url: "<?php echo $statuschangegotohome; ?>",
            type: "post",
            data: "id=" + id + "&go_to_home=" + status,
            dataType: "html",
            success: function(msg) {
                 $('#courses-grid').yiiGridView.update('courses-grid');
            }
        });

    }
</script>

<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'courses-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    //'afterAjaxUpdate' => 'reinstallDatePicker',
    'columns' => array(
        'course_titile',
        array(
            'name' => 'category_id',
            'value' => '$data->category->name',
            'filter' => CHtml::listData(Category::model()->findAll(array('condition' => 'status = ' . SkillConfig::STATUS_ACTIVE, 'order' => 'name ASC')), 'id', 'name'),
        ),
//        array(
//            'name' => 'create_time',
//            'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array(
//                'model' => $model,
//                'attribute' => 'create_time',
//                'language' => 'en',
//                'options' => array(// (#3)
//                    'showOn' => 'focus',
//                    'dateFormat' => 'yy-mm-dd',
//                    'altField' => '#Courses_create_time',
//                    'altFormat' => 'yy-mm-dd', // show to user format
//                    'showOtherMonths' => true,
//                    'selectOtherMonths' => true,
//                    'changeMonth' => true,
//                    'changeYear' => true,
//                ),
//                    ), true),
//        ),

         array(
            'name' => 'course_exp',
            'type' => 'raw',
            'value' => '($data->course_exp!=0)?"Yes":"No"',
            'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
        ),
        array(
            'name' => 'status',
            'type' => 'raw',
            'value' => 'changeStatusIngridView($data)',
            'filter' => array('0' => Yii::t('app', 'Inactive'), '1' => Yii::t('app', 'Active')),
        ),
         array(
            'name' => 'go_to_home',
            'type' => 'raw',
            'value' => 'gotohomePage($data)',
            'filter' => array('0' => Yii::t('app', 'Inactive'), '1' => Yii::t('app', 'Active')),
        ),
        array(
            'name' => 'backend_user_id',
            'header' => 'Course Created By',
            'value' => 'ClassIngridView($data)',
            'filter' => array(1 => Yii::t('app', 'Backend'), 0 => Yii::t('app', 'Frontend')),
        ),
        array(
            'header' => 'View-Query',
            'value' => 'Courses::checkQueryEmpty($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'header' => 'Review-Rating',
            'value' => 'Courses::checkClassesReview($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'header' => 'Content-Rate',
            'value' => 'Courses::contentRate($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'header' => 'Trainer Suggest',
            'value' => 'Courses::trainersuggest($data)',
            'type' => 'raw',
            'filter' => false,
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{view}{update}{delete}',
//            'buttons' => array(
//                'update' => array(
//                    'visible' => 'Classes::showUpdateButtion($data)', //A PHP expression for determining whether the button is visible.
//                ),
//            ),
        ),
    ),
));
//Yii::app()->clientScript->registerScript('re-install-date-picker', "
//function reinstallDatePicker(id, data) {
//    $('#Courses_create_time').datepicker(jQuery.extend(jQuery.datepicker.regional['en-GB'],
//	{'dateFormat':'yy-mm-dd'},{'showOtherMonths':true},{'selectOtherMonths':true},{'changeMonth':true},{'changeYear':true}));
//    $('#Courses_update_time').datepicker(jQuery.extend(jQuery.datepicker.regional['en-GB'],
//	{'dateFormat':'yy-mm-dd'},{'showOtherMonths':true},{'selectOtherMonths':true},{'changeMonth':true},{'changeYear':true}));
//}
//");
?>